package org.qiuer.run;

import org.qiuer.exception.Const;
import org.qiuer.exception.ERuntime;

public class Variable {
  private String name;
  private Object value;
  private boolean modifiable;

  public Variable(String name, Object value, boolean modifiable) {
    this.name = name;
    this.value = value;
    this.modifiable = modifiable;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public Object getValue() {
    return value;
  }

  public void setValue(Object value) throws ERuntime {
    if (!modifiable){
      throw new ERuntime(Const.EXCEPTION.UNSUPPORTED_EXPRESSION, "变量：" + name + "不支持修改值");
    }
    this.value = value;
  }

  public boolean isModifiable() {
    return modifiable;
  }
}
